import 'package:shared_preferences/shared_preferences.dart';

class LocalStorageUtil {

  LocalStorageUtil._();

  static Future<bool> remove(String key) async {
    SharedPreferences sp = await SharedPreferences.getInstance();
    return await sp.remove(key);
  }

  static Future<bool> setBool(String key, bool value) async {
    SharedPreferences sp = await SharedPreferences.getInstance();
    return await sp.setBool(key, value);
  }

  static Future<bool> getBool(String key, bool def) async {
    SharedPreferences sp = await SharedPreferences.getInstance();
    return sp.getBool(key) ?? def;
  }

  static Future<bool> setString(String key, String value) async {
    SharedPreferences sp = await SharedPreferences.getInstance();
    return await sp.setString(key, value);
  }

  static Future<String> getString(String key, String def) async {
    SharedPreferences sp = await SharedPreferences.getInstance();
    return sp.getString(key) ?? def;
  }

  static Future<bool> setInt(String key, int value) async {
    SharedPreferences sp = await SharedPreferences.getInstance();
    return await sp.setInt(key, value);
  }

  static Future<int> getInt(String key, int def) async {
    SharedPreferences sp = await SharedPreferences.getInstance();
    return sp.getInt(key) ?? def;
  }

  static Future<bool> setDouble(String key, double value) async {
    SharedPreferences sp = await SharedPreferences.getInstance();
    return await sp.setDouble(key, value);
  }

  static Future<double> getDouble(String key, double def) async {
    SharedPreferences sp = await SharedPreferences.getInstance();
    return sp.getDouble(key) ?? def;
  }
}
